#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from dragon.selector import Selector
from pages.strategybar import StrategyBar
from dragon.page import DraPage
from pages.calendar import Calendar

class StockTrack4Se:
    # 策略栏

    #
    calendarButton=Selector('div.sort-name>div','日期按钮')
    increaseSortButton=Selector('div.sort-item> div > div','涨幅排序按钮')
    includeTimeSortButton=Selector('div.demo4-sort>div>div:nth-child(2) >div','纳入时间排序按钮')
    plateButton=Selector('text=全部板块','全部板块按钮')
    sortButton=Selector('text=排序','排序按钮')
    changeCountButton=Selector('text=资金次数','资金次数排序按钮')
    acoButton=Selector('text=竞/流/开','竞流开按钮')
    labelButton=Selector('text=标签','标签按钮')

    # 股票列表
    stockBlock=Selector('div.infinite-list-item','股票块')
    stock=Selector('div.demo6-item-name>div','股票')
    stockCode = Selector('div.demo6-item-name>div>span', '股票代码')
    changeCount=Selector('div.demo6-item-moneyNum>span','异动次数')
    realtimeIncrease=Selector('div.demo6-item-BkName > div:nth-child(2) >span','实时涨幅')
    includeTime=Selector('div.naru','纳入时间')
    changeDetailButton=Selector('text=资金详情','资金详情按钮')

class StockTrackPage4(StrategyBar):
    def __init__(self, draPage: DraPage):
        self.draPage=draPage
        super().__init__(draPage)
        self.calendarButton = draPage.locator(StockTrack4Se.calendarButton)
        self.increaseSortButton = draPage.locator(StockTrack4Se.increaseSortButton)
        self.includeTimeSortButton = draPage.locator(StockTrack4Se.includeTimeSortButton)
        self.plateButton = draPage.locator(StockTrack4Se.plateButton)
        self.sortButton = draPage.locator(StockTrack4Se.sortButton)
        self.changeCountButton = draPage.locator(StockTrack4Se.changeCountButton)
        self.acoButton = draPage.locator(StockTrack4Se.acoButton)
        self.labelButton = draPage.locator(StockTrack4Se.labelButton)
        self.stockBlock = draPage.locator(StockTrack4Se.stockBlock)
        self.stock = draPage.locator(StockTrack4Se.stock)
        self.stockCode = draPage.locator(StockTrack4Se.stockCode)
        self.changeCount = draPage.locator(StockTrack4Se.changeCount)
        self.realtimeIncrease = draPage.locator(StockTrack4Se.realtimeIncrease)
        self.includeTime = draPage.locator(StockTrack4Se.includeTime)
        self.changeDetailButton = draPage.locator(StockTrack4Se.changeDetailButton)

    def pick_date_by_index(self, index: int):
        self.calendarButton.click()
        calendar = Calendar(self.draPage)
        calendar.pick_date_by_index(index)

















